<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>03_执行上下文栈2</title>
</head>
<body>
<!-- 
1、依次输出什么
    global begin:undefined
    foo() begin :1
    foo() begin :2
    foo() begin :3
    foo() end:3
    foo() end:2
    foo() end:1
    global end:1

2、整个过程中产生了几个执行上下文
-->
<script>
console.log("global begin:" + i) // ubdefined
var i = 1
foo(1)

function foo(i) {
    if (i == 4) {
        return
    }
    console.log("foo() begin :" + i) // 1 2 3
    foo(i + 1)
    console.log("foo() end:" + i) // 
}
console.log("global end:" + i)
</script>
</body>
</html>